package shanghaielectric_lib.Communication;

import android.util.Log;

import com.shanghai.shanghaielectric.Constants;
import com.shanghai.shanghaielectric.DataAdapter.WriteData2CellsAdapter;

import shanghaielectric_lib.Communication.Comm_Modbus.Comm_Modbus;
import shanghaielectric_lib.Communication.Comm_Modbus.Constants_modbus;
import shanghaielectric_lib.Communication.Comm_Modbus.ModbusThread;
import shanghaielectric_lib.EnumDataHelper;
import shanghaielectric_lib.Utils.LogUtil;

/**
 * Created by 45000460 on 2017/11/29.
 */

public class CommunicateManager {
    public static void sendData(  ){
        WriteData2CellsAdapter writeData2CellsAdapter=new WriteData2CellsAdapter();
      //初始化第一帧数据，动态获取
//        Constants.writeDataModel.totalCapacity=Constants.totalCapacity;
        writeData2CellsAdapter.writeDataToCells(Constants.writeDataModel);
        LogUtil.e("ccc",""+Constants.writeDataModel.controlCommand.getValue());
        ModbusThread.startWriteData();
    }

    public static void sendData_all(  ){
        Constants_modbus.isSettingState=true;
        WriteData2CellsAdapter writeData2CellsAdapter=new WriteData2CellsAdapter();
        //初始化第一帧数据，动态获取
//        Constants.writeDataModel.totalCapacity=Constants.totalCapacity;
        writeData2CellsAdapter.writeDataToCells(Constants.writeDataModel);
        LogUtil.e("ccc",""+Constants.writeDataModel.controlCommand.getValue());
        ModbusThread.startWriteData();
    }
    public static void clearData_0_3(){
        WriteData2CellsAdapter writeData2CellsAdapter=new WriteData2CellsAdapter();
        Constants.writeDataModel.controlCommand= EnumDataHelper.EnumWriteData_Command.CLEAR;
        Constants.writeDataModel.cleareSwitchTimes=0;
        writeData2CellsAdapter.writeDataToCells(Constants.writeDataModel);
    }
}
